package com.blogSystem.type.listener;

import com.blogSystem.type.client.BaseClient;
import com.blogSystem.type.pojo.Type;
import com.blogSystem.type.service.TypeService;
import org.springframework.amqp.rabbit.annotation.RabbitHandler;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.Map;

@Component
@RabbitListener(queues = "article")

public class TypeListener {
    @Autowired
    private TypeService typeService;
    @Autowired
    private BaseClient baseClient;
    @RabbitHandler
    public void executeSms(Map<String,String> map){
        String text=map.get("text");
        String _id=map.get("_id");
        System.out.println(text);
        Type type=typeService.getType(text);
        System.out.println("Type"+type.getType());
        baseClient.add_type(_id,type.getId());
    }
}
